﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebChat
{
    public partial class Chat : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void GetMessages(object sender, EventArgs e)
        {
            List<string> messages = (Application["ChatLog"] as List<string>);

            ChatLogBox.Text = "";
            for (int i = Math.Max(0, messages.Count - 100); i < messages.Count; i++)
            {
                ChatLogBox.Text += messages[i] + "\n";
            }
        }

        protected void SendMessage(object sender, EventArgs e)
        {
            (Application["ChatLog"] as List<string>).Add(Request.UserHostAddress +" [" + DateTime.Now.TimeOfDay + "]: "+ NewMessageBox.Text);
            NewMessageBox.Text = "";
        }
    }
}